#include<stdio.h>
#include <math.h> 
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
int N,P,W,H;
int T,sa,sapw;	//sum of a[],sum of a[i]/w
int a[1005];
int calcPages(int S){
	
	int i,w=W/S,h=H/S;
	sapw=0;
	for (i=0;i<N;i++){
		
		sapw+=(a[i]-1)/w+1;
	}
	return sapw/h;
	
}

int main(){
	int i,j,k;
	int p,smax,ans,s0,s1,s2;
	freopen("ms1.txt","r",stdin);
 
	if (scanf("%d", &T) != EOF) {
		while (T-->0){
			scanf("%d%d%d%d",&N,&P,&W,&H);
    		sa=0; 
    		for (i=0;i<N;i++){
	    		scanf("%d",&a[i]);
	    		sa+=a[i];
	     
	   		}
			 s1=sqrt(W*H*P/sa);  
			 s0=max(s1/2,1);;
			 s2=min(s1*2,min(W,H));
			 s0=1;s2=min(W,H); 
			ans=1,smax=1;
		 	for (j=s0;j<=s2;j++) {
		 		p=calcPages(j);
		 		if (p<=P) {
		 			smax=j;
				 }
	 		//printf("%d,,,",calcPages(j));
	 		
		 	}
			 
 			printf("%d\n",smax);
		}	

    }
	return 0;
} 